﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sharp.Domain.PlatformBoundedContext.PersonModule.Aggregates;
using Sharp.Domain.PlatformBoundedContext.UserModule.Aggregates;
using Sharp.Domain.Model;
using Sharp.Infrastructure;

namespace Sharp.Domain.PlatformBoundedContext.OrgModule.Aggregates
{
    /// <summary>
    /// 组织机构
    /// </summary>
    public partial class Org : AggregateRoot, IStandardEntity, IStandardState
    {
        public Org()
        {
            People = new List<Person>();
            Groups = new List<Group>();
            AuthorizedUsers = new List<User>();
        }

        /// <summary>
        /// 上级
        /// </summary>
        public System.Guid? ParentId { get; set; }
        /// <summary>
        /// 编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public int OrderIndex
        {
            get;
            set;
        }
        /// <summary>
        /// 名称
        /// </summary>
        /// <value>标题</value>
        [Display(Name = "名称")]
        public string Title { get; set; }
        /// <summary>
        /// 简称
        /// </summary>
        public string Abbreviation { get; set; }
        /// <summary>
        /// 层次Id
        /// </summary>
        public Guid? OrgLevelId { get; set; }

        /// <summary>
        /// 编制
        /// </summary>
        public int? MaxHeadcount { get; set; }

        /// <summary>
        /// 当前编制
        /// </summary>
        [Display(Name = "当前编制")]
        [NotMapped]
        public int? CurrentHeadcount { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        /// <value>备注</value>
        public string Remark { get; set; }


        /// <summary>
        /// 添加日期
        /// </summary>
        /// <value>添加日期</value>
        public System.DateTime? CheckInTime { get; set; }
        /// <summary>
        /// 录入员的id
        /// </summary>
        /// <value>录入员的id</value>
        public System.Guid? CheckInUserId { get; set; }
        /// <summary>
        /// 修改时间
        /// </summary>
        /// <value>修改时间</value>
        public System.DateTime? ModifiTime { get; set; }
        /// <summary>
        /// 修改数据的用户Id
        /// </summary>
        /// <value>修改数据的用户Id</value>
        public System.Guid? ModifiedUserId { get; set; }

        /// <summary>
        /// 层次
        /// </summary>
        /// <value>The org level.</value>
        [Display(Name = "层次")]
        public OrgLevel OrgLevel { get; set; }

        /// <summary>
        /// 组织路径
        /// </summary>
        /// <value>The org path.</value>
        public string OrgPath { get; set; }


        /// <summary>
        /// 部门内的员工
        /// </summary>

        public virtual ICollection<Person> People { get; set; }

        /// <summary>
        /// 组织包含的组
        /// </summary>
        public virtual ICollection<Group> Groups { get; set; }
        public virtual ICollection<Group> Groups1 { get; set; }
        /// <summary>
        /// Gets or sets the org for business list.
        /// </summary>
        public virtual ICollection<OrgForBusinessList> OrgForBusinessList { get; set; }

        /// <summary>
        /// 该组织已经授权的用户
        /// </summary>
        public virtual ICollection<User> AuthorizedUsers { get; set; }

        /// <summary>
        /// 该组织已经授权的用户组
        /// </summary>
        public virtual ICollection<UserGroup> AuthorizedUserGroups { get; set; }

        public EntityStateOperate EntityState { get; set; }
    }
}